package main

import (
	"fmt"
	"ginchat/models"

	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

func main() {
	db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
	if err != nil {
		panic("failed to connect database")
	}

	// Migrate the schema
	db.AutoMigrate(&models.UserBasic{})

	// Create
	user := &models.UserBasic{}
	user.Name = "qpf"
	db.Create(user)

	// Read
	fmt.Println(db.First(user, 1)) // find product with integer primary key

	// Update - update product's price to 200
	db.Model(user).Update("Password", "1234")

	// Delete - delete product
	// db.Delete(&product, 1)
}
